/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"A77F98FF-E86B-4932-9FA2-C80BFEE2C236"}
 */
function agregar(event) {
	ficha_clinica_to_ficha_detalle.newRecord()
	application.showFormInDialog(forms.ficha_detalle_dtl_carga,-1,-1,-1,-1,'Nuevo Detalle de Ficha',false,false,'FIDTL',true)
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"2DD0F744-CCA3-4059-81CC-D0C702427EC9"}
 */
function eliminar(event) {
	ficha_clinica_to_ficha_detalle.deleteRecord()
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"A5DF59F3-654B-4435-8AEA-254E400A6179"}
 */
function cerrar(event) {
	application.closeFormDialog('FICHA')
	databaseManager.setAutoSave(true)
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"240193D8-D51B-46F2-B05E-58CD2B17A60C"}
 */
function cancelar(event) {
	databaseManager.rollbackEditedRecords()
	cerrar()
}

/**
 * Perform the element default action.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @properties={typeid:24,uuid:"9BDB1A03-39EC-4E04-9F67-DDEE332EDEF0"}
 */
function grabar(event) {
	if (texto == '<Ingrese un texto...>')
		texto = ' '
	
	var $rel = ficha_clinica_to_ficha_detalle.getSize()
	for (var i = 1 ; i <= $rel ; i++)
	{
		if (ficha_clinica_to_ficha_detalle.estudios_id == null)
			ficha_clinica_to_ficha_detalle.deleteRecord()
	}
	databaseManager.saveData()
	cerrar()
}

/**
 * Handle focus element gaining focus.
 *
 * @param {JSEvent} event the event that triggered the action
 *
 * @returns {Boolean}
 *
 * @properties={typeid:24,uuid:"0830E415-0C35-4557-808A-86979971506B"}
 */
function onFocusGained(event) {
	if (texto == '<Ingrese un texto...>')
		texto = ' '
	return true
}
